﻿using System;
using System.Diagnostics;
using Rio.Applications.Web.Services.BusinessEntities;

namespace Rio.Framework.Pages.Helpers
{
    public class LoggerHelper
    {
        /// <summary>
        /// Sends the specified error message.
        /// Class and method will be retrieve automatically.
        /// </summary>
        /// <param name="p_sClassName">Name of the P_S class.</param>
        /// <param name="p_sErrorMessage">The error message.</param>
        public static void Send(string p_sClassName, string p_sErrorMessage)
        {
            try
            {
                //Create StackTrace to retrieve caller informations
                StackTrace stackTrace = new StackTrace();
                StackFrame stackFrame = stackTrace.GetFrame(1);

                //Build error Message
                String exceptionMessage = String.Format(
                    "{0} -> {1}",
                    p_sClassName,
                    stackFrame.GetMethod().Name);

                ToolsDS l_sdcToolsDomainContext = new ToolsDS();
                l_sdcToolsDomainContext.LogClientError(exceptionMessage, p_sErrorMessage);

            }
            catch
            {
            }
        }
    }
}
